#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 4e4 + 5;
const int INF = 1e6;
const ll MX = 1e18;
int n, m;
int a[N], len[N];
int st[N], top;
ll dp[N], sum1[N], sum2[N];

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  rep(i, 1, n) cin >> a[i];
  rep(i, 1, n) a[i] -= i;
  a[0] = -INF, a[n + 1] = INF;
  rep(i, 0, n + 1) {
    int id = lower_bound(st + 1, st + top + 1, a[i] + 1) - st;
    len[i] = id;
    if (id > top) top++;
    st[id] = a[i];
  }
  cout << n + 2 - len[n + 1] << endl;
  rep(i, 1, n + 1) {
    dp[i] = MX;
    per(j, i - 1, 0) {
      if (len[j] + 1 != len[i] || a[j] > a[i]) continue;
      sum1[j] = 0;
      rep(k, j + 1, i - 1) sum1[k] = sum1[k - 1] + abs(a[k] - a[j]);
      sum2[i] = 0;
      per(k, i - 1, j + 1) sum2[k] = sum2[k + 1] + abs(a[k] - a[i]);
      rep(k, j, i - 1) dp[i] = min(dp[i], dp[j] + sum1[k] + sum2[k + 1]);
    }
  }
  cout << dp[n + 1];
  return 0;
}